package org.testfire.realm.view.tags;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * Created by IntelliJ IDEA.
 * User: Granum
 * Date: Dec 10, 2006
 * Time: 4:59:52 PM
 */
public class HeaderUtil extends TagSupport {

	private String m_action;
	private Object m_key;
	private Object m_value;

	public HeaderUtil() {
		super();
	}


	public void setAction(String action) {
		m_action = action;
	}

	public void setKey(Object key) {
		this.m_key = key;
	}


	public void setValue(Object value) {
		m_value = value;
	}


	public int doEndTag() {
		HttpServletResponse resp = (HttpServletResponse) pageContext.getResponse();
		if(m_action == null || m_action.equals("string")){
			resp.addHeader(m_key.toString(), m_value.toString());
		}
		else if(m_action.equals("date")){
			resp.addDateHeader(m_key.toString(), new Long(String.valueOf(m_value)));
		}
		else if(m_action.equals("int")){
			resp.addIntHeader(m_key.toString(), new Integer(String.valueOf(m_value)));
		}
		return EVAL_PAGE;
	}

	


}
